package com.code.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * 说明: 分页参数
 *
 * @author :chengzi
 * Create :2020/5/14 10:55
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Accessors(chain = true)
@ApiModel(description = "分页入参对象")
public class PageParam<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(name = "pageIndex", value = "当前页码")
    private Integer pageIndex = 1;

    @ApiModelProperty(name = "pageSize", value = "每页条数")
    private Integer pageSize = 10;

    @ApiModelProperty(name = "params", value = "参数")
    private T params;

    public void setPageIndex(Integer pageIndex) {
        if(pageIndex == null || pageIndex < 1){
            pageIndex = 1;
        }
        this.pageIndex = pageIndex;
    }

    public void setPageSize(Integer pageSize) {
        if(pageSize == null || pageSize < 1){
            pageSize = 1;
        }
        this.pageSize = pageSize;
    }
}
